<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增疾病管理')" />
    <th:block th:include="include :: bootstrap-fileinput-css"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-disease-add">
        <div class="form-group">
            <label class="col-sm-3 control-label ">父级科目</label>
            <div class="col-sm-8">
                <div class="input-group">
                    <input id="treeId" name="pid" type="hidden" th:value="${disease?.id}"/>
                    <input class="form-control" placeholder="请选择父级疾病" type="text" onclick="selectDiseaseTree()" id="treeName" readonly="true" th:value="${disease?.name}">
                    <span class="input-group-addon"><i class="fa fa-search"></i></span>
                </div>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label is-required">疾病名称</label>
            <div class="col-sm-8">
                <input name="name" class="form-control" placeholder="请输入名称" type="text" required>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">排序</label>
            <div class="col-sm-8">
                <input name="sortid" class="form-control" placeholder="请输入排序数字" type="text">
            </div>
        </div>

    </form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: bootstrap-fileinput-js"/>
<script th:inline="javascript">
    var prefix = ctx + "old/disease"
    $("#form-disease-add").validate({
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/add", $('#form-disease-add').serialize());
        }
    }

    $(".file-upload").fileinput({
        uploadUrl: ctx + 'common/upload',
        maxFileCount: 1,
        autoReplace: true
    }).on('fileuploaded', function (event, data, previewId, index) {
        $("input[name='" + event.currentTarget.id + "']").val(data.response.fileName)
    }).on('fileremoved', function (event, id, index) {
        $("input[name='" + event.currentTarget.id + "']").val('')
    })

    /*疾病管理-新增-选择父疾病管理树*/
    function selectDiseaseTree() {
        var options = {
            title: '疾病管理选择',
            width: "480",
            url: prefix + "/selectDiseaseTree/" + $("#treeId").val(),
            callBack: doSubmit
        };
        $.modal.openOptions(options);
    }

    function doSubmit(index, layero){
        var body = $.modal.getChildFrame(index);
        $("#treeId").val(body.find('#treeId').val());
        $("#treeName").val(body.find('#treeName').val());
        $.modal.close(index);
    }
</script>
</body>
</html>